<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE HTML>
<html>
<head>
  <title>后台管理系统</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <link href="/resources/css/dpl-min.css" rel="stylesheet" type="text/css" />
  <link href="/resources/css/bui-min.css" rel="stylesheet" type="text/css" />
  <link href="/resources/css/page-min.css" rel="stylesheet" type="text/css" />
  <style type="text/css">
    code {
      padding: 0px 4px;
      color: #d14;
      background-color: #f7f7f9;
      border: 1px solid #e1e1e8;
    }
  </style>
</head>
<body>

<div class="container">
       <div class="row">
         <div class="control-group span12">
          开始时间： <input type="text" class="calendar calendar-date" name="startDate" id="startDate">
         <span> - </span>
          结束时间：<input name="endDate" type="text" class="calendar calendar-date" id="endDate">
          </div>

         <div class="control-group span2">
           <button  type="button"  class="button" onclick="submit()" id="query">搜索</button>
         </div>
      </div>
    <%--   <div class="row" style="margin-top:10px;">
         <div class="control-group span16">
           <label class="control-label">省份：
             <select id="province" name="province"  onchange="loadCity()">
             </select>
           </label>

           <label class="control-label">地市：

             <select id="city" name="city"  onchange="loadArea()">
               <option value="">请选择</option></select>
           </label>

           <label class="control-label">区县：

             <select id="area" name="area">
               <option value="">请选择</option>
             </select>
           </label>
         </div>--%>

       </div>
    <br/>
     <div class="search-grid-container">
       <div id="grid">
         <h2>销售统计</h2>
         <div style="width: 100%;height:100px;text-align: center;margin: 0 auto;" id="loading">
           <img src="/resources/images/loading.gif" style="width:40px;height: 40px;"/>
           <br/>
           <p style="font-size: 18px;">正在加载，请稍后......</p>
         </div>
         <div class="row" style="margin-top: 5px;" id="content">

         </div>

       </div>

     </div>
</div>
<script type="text/javascript" src="/resources/js/jquery-1.8.1.min.js"></script>
<script type="text/javascript" src="/resources/js/bui-min.js"></script>
<script type="text/javascript" src="/resources/js/config-min.js"></script>


<script type="text/javascript">
  BUI.use('common/page'); //页面链接跳转
  BUI.use(['bui/tree','bui/form','bui/calendar'],function (Tree,Form,Calendar) {
    var datepicker = new Calendar.DatePicker({
      trigger:'.calendar-date',
      showTime:false,
      autoRender : true
    });
  });

  Date.prototype.format = function(format, args) {
    var args = args || {};
    var o = {
      "M+" : args.month || this.getMonth() + 1, // month
      "d+" : args.date || this.getDate(), // day
      "h+" : args.hour || this.getHours(), // hour
      "m+" : args.minu || this.getMinutes(), // minute
      "s+" : args.second || this.getSeconds(), // second
      "q+" : Math.floor((this.getMonth() + 3) / 3), // quarter
      "S" : this.getMilliseconds()
      // millisecond
    };
    if (/(y+)/.test(format))
      format = format.replace(RegExp.$1, (this.getFullYear() + "")
              .substr(4 - RegExp.$1.length));
    for ( var k in o)
      if (new RegExp("(" + k + ")").test(format))
        format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k]
                : ("00" + o[k]).substr(("" + o[k]).length));
    return format;
  };
  $(function(){
    $("#query").click();
  })



  function submit(){
    $("#loading").show();
    $("#content").html("");
    $.ajax({
      url:"/product/queryProductData?r="+Math.random(),
      type:"post",
      data:{
        startDate:$("#startDate").val(),
        endDate:$("#endDate").val()
      },
      success:function(res){
        $("#loading").hide();
        var html = "";
        if(res.success){
           $.each(res.data,function(i,n){
              html += " <div class=\"span8\"><label>"+n.name+"：</label><span class=\"detail-text\"  style=\"cursor: pointer;\">"+n.num+"</span></div>";
           });

        }
        $("#content").html(html);
      },
      error:function(){}
    })
  }

   function loadProvince(){
     $.ajax({
     url:"/front/loadCitys?r="+Math.random(),
     type:"post",
     data:{
     pid:"0"
     },
     success:function(res){
     if(res.success){
     fillSelect("province",res.data);
     loadCity();
     }
     },
     error:function(){

     }
     })
   }
  function loadCity(){
    $.ajax({
      url:"/front/loadCitys?r="+Math.random(),
      type:"post",
      data:{
        pid:$("#province").val()
      },
      success:function(res){
        if(res.success){
          fillSelect("city",res.data);
          loadArea();
        }
      },
      error:function(){

      }
    });
  }
  function loadArea(){
    $.ajax({
      url:"/front/loadCitys?r="+Math.random(),
      type:"post",
      data:{
        pid:$("#city").val()
      },
      success:function(res){
        if(res.success){
          fillSelect("area",res.data);
        }
      },
      error:function(){

      }
    });
  }
  function fillSelect(id,data){
    var html = "<option value=''>请选择</option>";
    $.each(data,function(i,n){
      var ckd = "";
      html += "<option value='"+n.no+"' "+ckd+">"+n.name+"</option>";
    });
    $("#"+id).html(html);
  }

  function showDetails(i){

    top.topManager.openPage({id:"viewdetail",href:"/orderFx/list?index="+i+"&startDate="+$("#startDate").val()+"&endDate="+$("#endDate").val()+"&province="+$("#province").val()
    +"&city="+$("#city").val()+"&area="+$("#area").val(),title:"查看明细"});

    /*  window.location.href = "/orderFx/list?index="+i+"&startDate="+$("#startDate").val()+"&endDate="+$("#endDate").val()+"&province="+$("#province").val()
      +"&city="+$("#city").val()+"&area="+$("#area").val();*/
  }


  function showTdDetails(i){
    var date = new Date();
    var today = date.format('yyyy-MM-dd');

    top.topManager.openPage({id:"viewdetail",href:"/orderFx/list?index="+i+"&startDate="+today+"&endDate="+today+"&province="+$("#province").val()
    +"&city="+$("#city").val()+"&area="+$("#area").val(),title:"查看明细"});


  /*  window.location.href = "/orderFx/list?index="+i+"&startDate="+today+"&endDate="+today+"&province="+$("#province").val()
            +"&city="+$("#city").val()+"&area="+$("#area").val();*/
  }

</script>

</body>
</html> 